package com.china.svc.comprehensivetest.brushGather.ui.Activity;

import android.support.v4.app.Fragment;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.china.svc.comprehensivetest.R;
import com.china.svc.comprehensivetest.baseGather.base.BaseActivity;
import com.china.svc.comprehensivetest.brushGather.ui.Activity.fragment.newsFrament;
import com.china.svc.comprehensivetest.brushGather.ui.Activity.fragment.tabExploreFrament;
import com.china.svc.comprehensivetest.brushGather.ui.Activity.fragment.tabMeFrament;
import com.china.svc.comprehensivetest.brushGather.ui.Activity.fragment.tweetFrament;

import java.util.HashMap;

public class MainActivity extends BaseActivity {

    private RadioButton mTabNew;
    private RadioButton mTabTweet;
    private RadioButton mTabMe;
    private RadioButton mTabcontent;
    private RadioGroup mRadioGroup;


    @Override
    public int getLayoutRes() {
        return R.layout.activity_main;
    }


    @Override
    public void initView() {
        mRadioGroup = findView(R.id.fragment_content_rg_tabs);
        mTabNew = findView(R.id.tabNew);
        mTabTweet = findView(R.id.tabTweet);
        mTabMe = findView(R.id.tabMe);
        mTabcontent = findView(R.id.tabExplore);
    }

    @Override
    public void initListener() {

    }

    public HashMap<Integer, Fragment> fragmentMap = new HashMap();

    @Override
    public void initData() {
        fragmentMap.put(R.id.tabNew, new newsFrament());
        fragmentMap.put(R.id.tabExplore, new tabExploreFrament());
        fragmentMap.put(R.id.tabTweet, new tweetFrament());
        fragmentMap.put(R.id.tabMe, new tabMeFrament());
        RadioGroup radioGroup = findView(R.id.fragment_content_rg_tabs);
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                getSupportFragmentManager().beginTransaction().replace(R.id.tabcontent, fragmentMap.get(checkedId)).commit();
            }
        });
        //默认第一选项
        mRadioGroup.check(R.id.tabNew);
    }
}